package com.threadpool.mythread.case01;

import java.util.concurrent.CountDownLatch;

/**
 * @Author 李李李
 * @2020/4/25 22:23
 *
 * 减法计数器
 *
 */
public class Case04 {
    public static void main(String[] args) throws InterruptedException {
        //定义栅栏为7个
        CountDownLatch countDownLatch = new CountDownLatch(7);

        for (int i = 0; i < 7; i ++){
            new Thread(()->{
                System.out.println(Thread.currentThread().getName() + "==> go home");
                countDownLatch.countDown(); //栅栏减少操作
            },String.valueOf(i)).start();
        }

        countDownLatch.await(); //只有达到栅栏数量才会被唤醒  继续执行

        System.out.println("关门");
    }
}
